<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div class="wrap"></div>

    <script>
      let odiv = document.querySelector("div");
      let ajax = new XMLHttpRequest();
      ajax.open("get", "/index");
      ajax.send();
      ajax.onreadystatechange = function () {
        if (ajax.readyState == 4 && ajax.status == 200) {
          console.log(ajax.responseText);
          let data = JSON.parse(ajax.responseText);
          let str = "";
          data.forEach((element) => {
            str += `<ul>
        <li><img src="${element.picture}" alt=""> </li>
        <li>商品名称：${element.tradeName}</li>
        <li>价格：${element.price}</li>
        <li>股票：${element.stock}</li>
    </ul>`;
          });
          odiv.innerHTML = str;
        }
      };
    </script>
  </body>
</html>
